package com.freeter.luceneUtil;

import java.io.Reader;
import java.util.regex.Pattern;

import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.analysis.pattern.PatternTokenizer;

public  class PatternAnalyzer extends Analyzer {
String regex;
public PatternAnalyzer(String regex){
this.regex = regex;
}
public PatternAnalyzer(){
this.regex = "";
}
 
@Override
protected TokenStreamComponents createComponents(String fieldName) {
	return new TokenStreamComponents(new PatternTokenizer(Pattern.compile(regex),-1));
}
 
}